KY11 二叉树遍历
https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking
#include <stdio.h>
#include<stdlib.h>
typedef char BTNodeDateType;
typedef struct BTNode
{
    struct BTNode*left;
    struct BTNode*right;
    BTNodeDateType data;

}BTNode;

BTNode*BuyNewnode(BTNodeDateType x)
{
    BTNode*newnode=(BTNode*)malloc(sizeof(BTNode));
    if(newnode==NULL)
    {
        perror("malloc fail");
        return NULL;
    }
    newnode->left=NULL;
    newnode->right=NULL;
    newnode->data=x;
    return newnode;

}

BTNode*CreateBTree(char*a,int*pi)
{
    if(a[*pi]=='#')
    {
        (*pi)++;
        return NULL;
    }

    BTNode*root=BuyNewnode((a[*pi]));
    (*pi)++;
    root->left=CreateBTree(a, pi);
    root->right=CreateBTree(a, pi);
    
    return root;
}

void InOrder(BTNode*root)
{
    if(root==NULL)
    {
        return ;
    }

    InOrder(root->left);
    printf("%c ",root->data);
    InOrder((root->right));
}


int main()
{
    char a[100];
    scanf("%s",a);
    int i=0;
    BTNode*root=CreateBTree(a,&i);
    InOrder(root);
    return 0;
}